/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 * */

// AmzServer - Tototoy's server model.
// Author: tonyjobmails@gmail.com (tonyhack).
//
// Define class CommunicateTask.
//
// CommunicateTask is a task in the network layer. This is the basic unit in the
// network layer, uses to communicate with application layer and system socket.
//

#ifndef __COMMUNICATE__TASK__H
#define __COMMUNICATE__TASK__H

#include "application_task.h"

namespace amz {

class Epoller;

class CommunicateTask : public ApplicationTask {
 public:
  explicit CommunicateTask(
         const ring_queue_define::RingQueueConfigure &configure) :
         ApplicationTask(configure) {}
  virtual ~CommunicateTask() {}

  // Register/Unregister to epoll.
  bool Register(Epoller &epoller, int events) = 0;
  bool Unregister(Epoller &epoller) = 0;

  // Communicate with application layer.
  virtual bool SendApplication() = 0;
  virtual bool ReceiveApplication() = 0;

  // Communicate with socket.
  virtual bool Send() = 0;
  virtual bool Receive() = 0;
};

}  // namespace amz

#endif  // __COMMUNICATE__TASK__H

